var _table =null;
$(document).ready(function(){



	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	

	//添加验证
    $("#fr_dictregion").validate({
        rules: {
			"name": {
				required: true
			},
			"code": {
				required: true
			},
			"level": {
				required: true
			},
			"pcode": {
				required: true
			},
			"p1code": {
				required: true
			},
			"p2code": {
				required: true
			},
			"creater": {
				required: true
			},
			"gmt_create": {
				required: true
			},
			"modifier": {
				required: true
			},
			"gmt_modified": {
				required: true
			},
        },
        onkeyup:false,
		focusCleanup:true,
		success:"valid",
    });

	
	var id = $("#id").val();
	if(id != ''){
		//回填数据
		ajaxRequestJson("getDictRegionById",{
			"id":id
		},function(result){
			$("#fr_dictregion").populate(result,"");
		})
	}
	
	$("#sub_mitbtn").on("click",function(){
		if($("#fr_dictregion").valid()){
			var json_str = $("#fr_dictregion").serializeJson();
			if(id != ''){
				ajaxRequestJson("updateDictRegion",json_str,function(sh_result){
					if(sh_result>0){
						show_alert('修改成功',function(){layer_close()});
					}
				});
			}else{
				ajaxRequestJson("saveDictRegion",json_str,function(sh_result){
					if(sh_result>0){
						
						show_alert('保存成功',function(){layer_close()});
						
					}
				});
			}
		}
	})






});


